﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using FlickrNet;

namespace FlickrDownloadr.UI.Controls
{
    public class PhotoListView : ListView
    {
        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            base.OnDrawItem(e);

            Graphics g = e.Graphics;

            Photo photoContainer = (Photo)e.Item.Tag;

            int padding = 2;

            if (photoContainer.License != LicenseType.AllRightsReserved)
            {
                int leftIndex = padding;
                leftIndex += e.Bounds.Y;

                g.DrawImage(Properties.Resources.cc, e.Bounds.X + 2, e.Bounds.Y + 2, 16, 16);

                foreach (Image img in Watermark.Watermarks[photoContainer.License])
                {
                    leftIndex += 18;
                    g.DrawImage(img, e.Bounds.X + 2, leftIndex, 16, 16);
                }
            }
            else
            {
                g.DrawImage(Watermark.Watermarks[LicenseType.AllRightsReserved][0], e.Bounds.X + 2, e.Bounds.Y + 2, 16, 16);
            }
            
            //Rectangle rect2 = new Rectangle(0, 0, 16, 16);
            //g.DrawImage(Properties.Resources.cc, e.Bounds.X + 2, e.Bounds.Y + 2, 16, 16);
        }
    }
}
